/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * POS_CheckoutCardAmount.java
 *
 * Created on Apr 7, 2011, 6:17:32 PM
 */

package POS_Source;

import POS_Controller.POSController;
import Session.POS_SessionManager;
import Utilities.MoneyFormatter;
import java.text.DecimalFormat;

/**
 * this class renders checkout by card view
 * @author edaype
 * @see POS_Source
 */
public class POS_CheckoutCardAmount extends javax.swing.JPanel {

    private POSController controller;
    private DecimalFormat formatter;
    private double amount;
    private DecimalFormat doubleFormat;



    /**
     * constructor for this class
     * @param control
     */
    public POS_CheckoutCardAmount(POSController control) {
        controller = control;
        formatter = new DecimalFormat(".00");
        initComponents();
        amount = 0.0;
        doubleFormat = new DecimalFormat(".00");
    }

    /**
     * this method formats and ads text to field
     * @param number
     */
    private void addTextToField(String number){
        amount *= 10;
        amount += Double.parseDouble(number)/100;
        AmountField.setText(formatter.format(amount));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        TitlePanel = new javax.swing.JPanel();
        TitleLabel = new javax.swing.JLabel();
        CashButton = new javax.swing.JButton();
        PayButton = new javax.swing.JButton();
        MainPanel = new javax.swing.JPanel();
        InstructionLabel = new javax.swing.JLabel();
        OrLabel = new javax.swing.JLabel();
        FullAmountButton = new javax.swing.JButton();
        AmountLabel = new javax.swing.JLabel();
        KeypadPanel = new javax.swing.JPanel();
        OneButton = new javax.swing.JButton();
        TwoButton = new javax.swing.JButton();
        ThreeButton = new javax.swing.JButton();
        SixButton = new javax.swing.JButton();
        FiveButton = new javax.swing.JButton();
        FourButton = new javax.swing.JButton();
        NineButton = new javax.swing.JButton();
        EightButton = new javax.swing.JButton();
        SevenButton = new javax.swing.JButton();
        ClearButton = new javax.swing.JButton();
        ZeroButton = new javax.swing.JButton();
        EraseButton = new javax.swing.JButton();
        AmountPane = new javax.swing.JScrollPane();
        AmountField = new javax.swing.JTextArea();
        InstructionsLabel1 = new javax.swing.JLabel();
        ErrorLabel = new javax.swing.JLabel();

        setBackground(new java.awt.Color(255, 255, 255));

        TitlePanel.setBackground(new java.awt.Color(255, 255, 255));

        TitleLabel.setFont(new java.awt.Font("Copperplate Gothic Bold", 2, 60));
        TitleLabel.setText("Payment");

        CashButton.setBackground(new java.awt.Color(255, 255, 255));
        CashButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        CashButton.setText("Pay by Cash");
        CashButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CashButtonActionPerformed(evt);
            }
        });

        PayButton.setBackground(new java.awt.Color(255, 255, 255));
        PayButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        PayButton.setText("Pay");
        PayButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PayButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout TitlePanelLayout = new javax.swing.GroupLayout(TitlePanel);
        TitlePanel.setLayout(TitlePanelLayout);
        TitlePanelLayout.setHorizontalGroup(
            TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TitlePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(TitleLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 314, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(305, 305, 305)
                .addComponent(CashButton, javax.swing.GroupLayout.PREFERRED_SIZE, 186, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(PayButton, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(17, 17, 17))
        );
        TitlePanelLayout.setVerticalGroup(
            TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TitlePanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(TitlePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(PayButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(CashButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(TitleLabel))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        MainPanel.setBackground(new java.awt.Color(255, 255, 255));
        MainPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        InstructionLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        InstructionLabel.setText("Please specify the amount you wish to charge on your card");

        OrLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        OrLabel.setText("Or");

        FullAmountButton.setBackground(new java.awt.Color(255, 255, 255));
        FullAmountButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        FullAmountButton.setText("Full Amount");
        FullAmountButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FullAmountButtonActionPerformed(evt);
            }
        });

        AmountLabel.setFont(new java.awt.Font("Tahoma", 0, 24));
        AmountLabel.setText("Amount:");

        KeypadPanel.setBackground(new java.awt.Color(255, 255, 255));

        OneButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        OneButton.setText("1");
        OneButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OneButtonActionPerformed(evt);
            }
        });

        TwoButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        TwoButton.setText("2");
        TwoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                TwoButtonActionPerformed(evt);
            }
        });

        ThreeButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        ThreeButton.setText("3");
        ThreeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ThreeButtonActionPerformed(evt);
            }
        });

        SixButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        SixButton.setText("6");
        SixButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SixButtonActionPerformed(evt);
            }
        });

        FiveButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        FiveButton.setText("5");
        FiveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FiveButtonActionPerformed(evt);
            }
        });

        FourButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        FourButton.setText("4");
        FourButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FourButtonActionPerformed(evt);
            }
        });

        NineButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        NineButton.setText("9");
        NineButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NineButtonActionPerformed(evt);
            }
        });

        EightButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        EightButton.setText("8");
        EightButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EightButtonActionPerformed(evt);
            }
        });

        SevenButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        SevenButton.setText("7");
        SevenButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SevenButtonActionPerformed(evt);
            }
        });

        ClearButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        ClearButton.setText("C");
        ClearButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ClearButtonActionPerformed(evt);
            }
        });

        ZeroButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        ZeroButton.setText("0");
        ZeroButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ZeroButtonActionPerformed(evt);
            }
        });

        EraseButton.setFont(new java.awt.Font("Tahoma", 0, 24));
        EraseButton.setText("<-");
        EraseButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EraseButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout KeypadPanelLayout = new javax.swing.GroupLayout(KeypadPanel);
        KeypadPanel.setLayout(KeypadPanelLayout);
        KeypadPanelLayout.setHorizontalGroup(
            KeypadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(KeypadPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(KeypadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(KeypadPanelLayout.createSequentialGroup()
                        .addComponent(OneButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(TwoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ThreeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(KeypadPanelLayout.createSequentialGroup()
                        .addComponent(FourButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(FiveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(SixButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(KeypadPanelLayout.createSequentialGroup()
                        .addComponent(SevenButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(EightButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(NineButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(KeypadPanelLayout.createSequentialGroup()
                        .addComponent(ClearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(ZeroButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(EraseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        KeypadPanelLayout.setVerticalGroup(
            KeypadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(KeypadPanelLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(KeypadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(OneButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(TwoButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ThreeButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(KeypadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(FourButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(FiveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(SixButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(KeypadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SevenButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EightButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(NineButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(KeypadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ClearButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ZeroButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EraseButton, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        AmountField.setColumns(10);
        AmountField.setFont(new java.awt.Font("Lucida Grande", 0, 18));
        AmountField.setRows(1);
        AmountPane.setViewportView(AmountField);

        javax.swing.GroupLayout MainPanelLayout = new javax.swing.GroupLayout(MainPanel);
        MainPanel.setLayout(MainPanelLayout);
        MainPanelLayout.setHorizontalGroup(
            MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, MainPanelLayout.createSequentialGroup()
                .addGap(78, 78, 78)
                .addComponent(FullAmountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(72, 72, 72)
                .addComponent(OrLabel)
                .addGap(57, 57, 57)
                .addComponent(KeypadPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(61, 61, 61))
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(InstructionLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 644, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(34, Short.MAX_VALUE))
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addGap(202, 202, 202)
                .addComponent(AmountLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(AmountPane, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(236, Short.MAX_VALUE))
        );
        MainPanelLayout.setVerticalGroup(
            MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MainPanelLayout.createSequentialGroup()
                .addGap(39, 39, 39)
                .addComponent(InstructionLabel)
                .addGap(33, 33, 33)
                .addGroup(MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(AmountPane, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
                    .addComponent(AmountLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(MainPanelLayout.createSequentialGroup()
                        .addGap(91, 91, 91)
                        .addGroup(MainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(OrLabel)
                            .addComponent(FullAmountButton, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(KeypadPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(31, 31, 31))
        );

        InstructionsLabel1.setFont(new java.awt.Font("Tahoma", 0, 10));
        InstructionsLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/POS_Source/images/Logo.png"))); // NOI18N
        InstructionsLabel1.setText(" ");

        ErrorLabel.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        ErrorLabel.setForeground(new java.awt.Color(255, 0, 0));
        ErrorLabel.setText(" ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(InstructionsLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(TitlePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 975, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(137, 137, 137)
                        .addComponent(MainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(210, Short.MAX_VALUE)
                .addComponent(ErrorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 586, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(199, 199, 199))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(InstructionsLabel1)
                .addGap(18, 18, 18)
                .addComponent(MainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(ErrorLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26)
                .addComponent(TitlePanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(27, 27, 27))
        );
    }// </editor-fold>//GEN-END:initComponents
/**
 * this method handles full payment button press action
 * @param evt
 */
    private void FullAmountButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FullAmountButtonActionPerformed
        
        POS_SessionManager smgr = controller.getSessionManager();
        AmountField.setText(doubleFormat.format(smgr.totalDue()));
    }//GEN-LAST:event_FullAmountButtonActionPerformed
/**
 * this method handles payment button press event
 * @param evt
 */
    private void PayButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PayButtonActionPerformed
        double amnt = 0.0;
        if(!AmountField.getText().isEmpty()){
            amnt = Double.parseDouble(AmountField.getText());
            if (!Double.isNaN(amnt)){
                if(controller.getSessionManager().totalDue() < amnt){
                    ErrorLabel.setText("You have entered more than you owe. Please re-enter amount.");
                    AmountField.setText("");
                    amount = 0.0;
                }
                else{
                    controller.makeCCPayment(amnt);
                }
            }
        }
    }//GEN-LAST:event_PayButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void OneButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OneButtonActionPerformed
        addTextToField("1");
}//GEN-LAST:event_OneButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void TwoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TwoButtonActionPerformed
        addTextToField("2");
}//GEN-LAST:event_TwoButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void ThreeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ThreeButtonActionPerformed
        addTextToField("3");
}//GEN-LAST:event_ThreeButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void SixButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SixButtonActionPerformed
        addTextToField("6");
}//GEN-LAST:event_SixButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void FiveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FiveButtonActionPerformed
        addTextToField("5");
}//GEN-LAST:event_FiveButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void FourButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FourButtonActionPerformed
        addTextToField("4");
}//GEN-LAST:event_FourButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void NineButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NineButtonActionPerformed
        addTextToField("9");
}//GEN-LAST:event_NineButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void EightButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EightButtonActionPerformed
        addTextToField("8");
}//GEN-LAST:event_EightButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void SevenButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SevenButtonActionPerformed
        addTextToField("7");
}//GEN-LAST:event_SevenButtonActionPerformed
/**
 * this method handles clear button press event
 * @param evt
 */
    private void ClearButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClearButtonActionPerformed
        AmountField.setText("");
        amount = 0.0;
}//GEN-LAST:event_ClearButtonActionPerformed
/**
 * this method handles  button press event
 * @param evt
 */
    private void ZeroButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ZeroButtonActionPerformed
        addTextToField("0");
}//GEN-LAST:event_ZeroButtonActionPerformed
/**
 * this method handles erase button press event
 * @param evt
 */
    private void EraseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EraseButtonActionPerformed
        if (AmountField.getText().length() > 0){
            amount *= 10;
            amount/=100;
            amount -= amount%0.01;
            System.out.println(amount);
            if (amount > 0.0)
                AmountField.setText(formatter.format(amount));
            else
                AmountField.setText("");
        }
    }//GEN-LAST:event_EraseButtonActionPerformed
/**
 * this method handles cash button press event
 * @param evt
 */
    private void CashButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CashButtonActionPerformed
        controller.CashPaymentScreen();
    }//GEN-LAST:event_CashButtonActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea AmountField;
    private javax.swing.JLabel AmountLabel;
    private javax.swing.JScrollPane AmountPane;
    private javax.swing.JButton CashButton;
    private javax.swing.JButton ClearButton;
    private javax.swing.JButton EightButton;
    private javax.swing.JButton EraseButton;
    private javax.swing.JLabel ErrorLabel;
    private javax.swing.JButton FiveButton;
    private javax.swing.JButton FourButton;
    private javax.swing.JButton FullAmountButton;
    private javax.swing.JLabel InstructionLabel;
    private javax.swing.JLabel InstructionsLabel1;
    private javax.swing.JPanel KeypadPanel;
    private javax.swing.JPanel MainPanel;
    private javax.swing.JButton NineButton;
    private javax.swing.JButton OneButton;
    private javax.swing.JLabel OrLabel;
    private javax.swing.JButton PayButton;
    private javax.swing.JButton SevenButton;
    private javax.swing.JButton SixButton;
    private javax.swing.JButton ThreeButton;
    private javax.swing.JLabel TitleLabel;
    private javax.swing.JPanel TitlePanel;
    private javax.swing.JButton TwoButton;
    private javax.swing.JButton ZeroButton;
    // End of variables declaration//GEN-END:variables

}
